package com.huiztech.kaoqinji;

import com.baidu.mapapi.BMapManager;
import com.huiztech.util.FileUtil;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.util.LogUtils;

import android.annotation.SuppressLint;
import android.app.Application;
import android.content.Context;
import android.os.Environment;

public class LocApplication extends Application {

    public BMapManager mBMapManager = null;
    public long visitTime;
    public String isStart;
    public int acquisition_interval;
    public static DbUtils db;
    public static final String DB_NAME = "remark.db";
    public static final String PACKAGE_NAME = "com.huiztech.kaoqinji";
    public static final String DB_PATH = "/data" + Environment.getDataDirectory().getAbsolutePath() + "/"
            + PACKAGE_NAME;

    public int getAcquisition_interval() {
        return acquisition_interval;
    }

    public void setAcquisition_interval(int acquisition_interval) {
        this.acquisition_interval = acquisition_interval;
    }

    public void setVistTime(long visitTime) {
        this.visitTime = visitTime;
    }

    public long getVisitTime() {
        return this.visitTime;
    }

    public void setIsStart(String isStart) {
        this.isStart = isStart;
    }

    public String getIsStart() {
        return this.isStart;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        initEngineManager(this);
        db=initDB();
    }
    @SuppressLint("SdCardPath")
    public DbUtils initDB() {
          LogUtils.i(FileUtil.isSdCardMounted()+"++"+FileUtil.sdcardPath());
          DbUtils db = null;
          if (FileUtil.isSdCardMounted()) {
              db = DbUtils.create(getApplicationContext(), FileUtil.sdcardPath(), "ddd");
              LogUtils.i(db+"++");
          } else {
              db = DbUtils.create(getApplicationContext());
          }
          db.configAllowTransaction(true);
          db.configDebug(true);
        return db;
    }

    public void initEngineManager(Context context) {
        if (mBMapManager == null) {
            mBMapManager = new BMapManager(context);
        }
        mBMapManager.init(AppConst.API_KEY, null);
    }

}
